package com.qst.songList.controller;


import com.qst.domain.entity.Mess;
import com.qst.domain.entity.SongList;
import com.qst.songList.service.ListMusicService;
import com.qst.songList.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/songList")
public class SongListController {
    @Autowired
    SongListService songListService;
    @Autowired
    ListMusicService listMusicService;
    @GetMapping("/search")
    public Mess search(String keyword){
        return songListService.search(keyword);
    }

    @GetMapping("/recommendList")
    public Mess recommendList(){
        return songListService.recommendList();
    }

    @GetMapping("/select")
    public Mess select(Integer listId, @RequestHeader(value = "id",required = false)Integer id){
        return songListService.getSongList(listId,id);
    }
    @PostMapping("/create")
    public Mess createList(@RequestBody SongList songList,@RequestHeader("id")Integer id) {
        return songListService.createList(songList,id);
    }

    @GetMapping("/getMySongList")
    public Mess getMySongList(@RequestHeader("id")Integer id){
        return songListService.getMySongList(id);
    }


    @PostMapping("/addSong")
    public Mess addSong(Integer songId,Integer listId){
        return listMusicService.addSong(songId,listId);
    }
    @PostMapping("/removeSong")
    public Mess removeSong(Integer songId,Integer listId){
        return listMusicService.removeSong(songId,listId);
    }
    @PostMapping("/removeSongList")
    public Mess removeSongList(Integer listId,@RequestHeader("id")Integer id) {
;
        return songListService.removeSongList(listId,id);
    }

}
